import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:share_fit/app/components/back_btn_icon.dart';
import 'package:share_fit/app/controllers/device/restoration/restoration_logic.dart';
import 'package:share_fit/app/controllers/device/restoration/warn_dialog.dart';
import 'package:share_fit/app/helper/ext/tr_ext.dart';
import 'package:share_fit/app/tools/color_const.dart';
import 'package:share_fit/generated/locales.g.dart';

class RestorationPage extends StatelessWidget {

  final logic = Get.put(RestorationLogic());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(LocaleKeys.restoration_device.ts, style: TextStyle(fontSize: 54.sp, color: ColorConst.btnFontColor),),
        centerTitle: true,
        leading: BackBtnIcon(onTap: () => Get.back()),
        // leading: IconButton(
        //   padding: EdgeInsets.only(left: 15,),
        //   icon: Image.asset("assets/images/space/icon_appbar_arrow_back.png"),
        //   onPressed: () { Get.back(); },
        //   // child: Image.asset("images/icon_appbar_arrow_back.png"),
        // ),
        // leadingWidth: 25,
      ),
      body: Column(
        children: [
          Container(
            width: 1.sw,
            alignment: Alignment.center,
            margin: EdgeInsets.only(top: 127.h),
            child: Image(
              width: 327.w,
              height: 266.h,
              image: const AssetImage("assets/images/device/icon_restoration.png"),
            ),
          ),
          // GestureDetector(
          //   behavior: HitTestBehavior.opaque,
          //   onTap: (){},
          //   child: Container(
          //     margin: EdgeInsets.fromLTRB(42.w, 138.h, 42.w, 0),
          //     padding: EdgeInsets.fromLTRB(62.w, 50.h, 56.w, 50.h),
          //     decoration: BoxDecoration(
          //         borderRadius: BorderRadius.circular(10),
          //         color: Colors.white
          //     ),
          //     child: Row(
          //       mainAxisAlignment: MainAxisAlignment.spaceBetween,
          //       children: [
          //         Text(LocaleKeys.restoration_device_setting.ts, style: TextStyle(fontSize: 42.sp, color: ColorConst.btnFontColor,)),
          //         Image(
          //             width: 36.w,
          //             height: 21.h,
          //             image: const AssetImage("assets/images/device/icon_restoration_arrow.png"))
          //       ],
          //     ),
          //   ),
          // ),
          Row(
            children: [
              Expanded(
                  child: Container(
                    height: 136.h,
                    margin: EdgeInsets.fromLTRB(42.h, 439.h, 42.h, 80.h),
                    child: ElevatedButton(
                      onPressed: () {Get.back();},
                      style: ButtonStyle(
                          backgroundColor: MaterialStateProperty.all(Color(0xFFD2D2D2)),
                          shape: MaterialStateProperty.all(RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(10)
                          ))
                      ),
                      child: Text(LocaleKeys.person_choice_cancel.ts, style: TextStyle(fontSize: 48.sp, color: Color(0xFF898C8F), ),),
                    ),
                  )),
            ],
          ),
          Row(
            children: [
              Expanded(
                  child: Container(
                    height: 136.h,
                    margin: EdgeInsets.fromLTRB(42.h, 0.h, 42.h, 0),
                    child: ElevatedButton(
                      onPressed: () {
                        showDialog(context: context, builder: (_){
                          return WarnDialog(callback: (_){
                            logic.resetFactory(back: (value) {
                              if(value) {
                                Get.back(result: value);
                              }
                            });
                          });
                        });
                      },
                      style: ButtonStyle(
                          backgroundColor: MaterialStateProperty.all(ColorConst.activeColor),
                          shape: MaterialStateProperty.all(RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(10)
                          ))
                      ),
                      child: Text(LocaleKeys.person_choice_submit.ts, style: TextStyle(fontSize: 48.sp, color: Colors.white, ),),
                    ),
                  )),
            ],
          )
        ],
      ),
    );
  }
}